﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.Odbc;
using System.Text;
using System.Xml;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class Partner_Pricerunner : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ReviewerMySql SQL = new ReviewerMySql();
        OdbcDataReader Reader = SQL.ExecuteReader("SELECT V2_Anmeldelse.*, V2_Distributor.Navn AS DisNavn, V2_GloFormat.Navn AS FormatNavn, V2_Spil.Format AS FormatID, V2_Spil.SpilID AS USpilID, V2_Writters.Navn AS NavnForfatter, V2_Spil.Titel, V2_GloGenres.Navn AS Genre, V2_Spil.ID AS RealID FROM V2_Anmeldelse JOIN V2_Spil ON V2_Spil.ID = V2_Anmeldelse.SpilID JOIN V2_GloGenres ON V2_GloGenres.ID = V2_Spil.Genre JOIN V2_GloFormat ON V2_GloFormat.ID = V2_Spil.Format JOIN V2_Writters ON V2_Writters.ID = V2_Anmeldelse.Forfatter JOIN V2_Distributor ON V2_Distributor.id = V2_Anmeldelse.Dis ORDER BY V2_Anmeldelse.ID DESC");
        XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
        writer.Formatting = Formatting.None;
        writer.WriteStartDocument();
        writer.WriteStartElement("Products");
        while(Reader.Read()) 
        {
            writer.WriteStartElement("Product");
            writer.WriteElementString("SKU", Reader["ID"].ToString());
            writer.WriteElementString("Category", "Spil: " + Reader["FormatNavn"].ToString());
            writer.WriteElementString("ProductName", Reader["Titel"].ToString());
            writer.WriteElementString("SubjectOfReview", Reader["Titel"].ToString());
            writer.WriteElementString("URL", "http://www.reviewer.dk/" + UI.LinkMake.LinkReview(Reader["ID"].ToString(), Reader["Titel"].ToString()));
            writer.WriteElementString("Summary", Reader["Header"].ToString());
            writer.WriteElementString("Grade", Reader["Karakter"].ToString());
            writer.WriteElementString("MaxGrade", "6");
            writer.WriteElementString("Author", Reader["NavnForfatter"].ToString());
            writer.WriteElementString("Date", Reader["Dato"].ToString());
            writer.WriteEndElement();
        }
        writer.WriteEndElement();
        writer.WriteEndDocument();
        writer.Flush();
        writer.Close();
        //Response.Write(writer);

    }
}
